/*
 * Copyright (c) 2006-2025, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2025-06-17     RT-Thread    first version
 */

#include <rtthread.h>
#include <LCD_ST7735S.h>
#include <bsp.h>


#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>

// LED 闪烁函数
static void led_blink(void)
{
    static int state = 0;
    if (state == 0)
    {
        led_control(LED_R_PIN, 0); // 点亮LED
    }
    else
    {
        led_control(LED_R_PIN, 1); // 熄灭LED
    }
    state = !state; // 切换状态
}

void LCD_init_fill(void)
{
    LCD_DisplayOn();
    lcdClear(WHITE);
    LCD_DrawRectangle(2,2,157, 77,GREEN);
    LCD_DrawLine(2,27,157,27, GREEN);
    LCD_DrawLine(2,52,157,52, GREEN);
    LCD_DrawLine(27,2,27,77, GREEN);
    LCD_DrawLine(132,2,132,77, GREEN);

    LCD_ShowString(10,3, 24, 24, 24, "U", DARKBLUE, WHITE);
    LCD_ShowString(10,28, 24, 24, 24, "I", DARKBLUE, WHITE);
    LCD_ShowString(10,53, 24, 24, 24, "P", DARKBLUE, WHITE);
    LCD_ShowString(140,3, 24, 24, 24, "v", DARKBLUE, WHITE);
    LCD_ShowString(140,28, 24, 24, 24, "A", DARKBLUE, WHITE);
    LCD_ShowString(140,53, 24, 24, 24, "W", DARKBLUE, WHITE);
}



int main(void)
{
    lcdInit();
    LCD_init_fill();
    bsp_init();


    while (1)
    {
        led_blink();
        rt_thread_mdelay(500);
    }

    return RT_EOK;
}
